package model;

import model.type.SubjectType;
import db.ImbiConnection;

public class Customer {
	private final int id;
	private int subject;
	private int subjectType;
		
	public Customer(int id, int subject, int subjectType) {
		super();
		this.id = id;
		this.subject = subject;
		this.subjectType = subjectType;
	}
	
	public int getSubject() {
		return subject;
	}

	public void setSubject(int subject) {
		this.subject = subject;
	}

	public int getSubjectType() {
		return subjectType;
	}

	public void setSubjectType(int subjectType) {
		this.subjectType = subjectType;
	}

	public int getId() {
		return id;
	}
	
	/*OBJECT ACCESS METHODS*/
	
	public String getSubjectTypeString(){
		return SubjectType.getSubjectType(getSubjectType()).getType();
	}
	
	public Object getSubjectObject(){
		if(getSubjectType() == SubjectType.ENTERPRISE)
			return ImbiConnection.getEnterpriseDAO().find(getSubject());
		if(getSubjectType() == SubjectType.PERSON)
			return ImbiConnection.getPersonDAO().find(getSubject());
		return null;
	}
	
}
